package cn.cvs.service;

import cn.cvs.dao.SupplierMapper;
import cn.cvs.pojo.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService{
    @Autowired
    private SupplierMapper mapper;
    @Override
    public List<Supplier> getSupplierList(String supCode, String supName, int pageIndex, int pageSize) {
        int startIndex = (pageIndex - 1) * pageSize;
        return mapper.getSupplierListBySupplier(supCode,supName,startIndex,pageSize);
    }

    @Override
    public int getListSize(String supCode,String supName) {
        return mapper.supplierCount(supCode,supName);
    }

    @Override
    public boolean add(Supplier supplier) {
        return mapper.insert(supplier) > 0;
    }

    @Override
    public Supplier getSupplier(int id) {
        return mapper.selectSupplierById(id);
    }

    @Override
    public boolean modify(Supplier supplier) {
        return mapper.update(supplier) > 0;
    }

    @Override
    public boolean delete(int id) {
        return mapper.delete(id) > 0;
    }
}
